﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Core;
using ColorLife.Core.Helper;
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        var tenDangNhap = txtUserName.Text.Trim();
        var matKhau = txtPassword.Text.Trim();

        var nguoiDung = NguoiDung.Login(tenDangNhap, matKhau.EncodePassword());
        if (nguoiDung != null)
        {
            Session["Login"] = nguoiDung;
            Response.Redirect("/MainPage.aspx");
        }
        else
        {
            Session["Login"] = null;
            lblMsg.Text = "Đăng nhập thất bại. Vui lòng thử lại.";
        }
    }
}